#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<int> countBits(int n)
    {
        vector<int> ret(n + 1);
        for (int i = 0; i <= n; i++)
            for (int j = 0; j < 31; j++)
                if ((i >> j) & 1 == 1) ret[i]++;

        return ret;
    }
};